package com.ganzalang.gmall.promotion.service.rule.profit.factory;

import com.ganzalang.gmall.promotion.enums.ProfitEnum;
import com.ganzalang.gmall.promotion.service.rule.profit.ProfitStrategy;
import com.ganzalang.gmall.promotion.service.rule.profit.impl.FixAmountStrategyImpl;
import com.ganzalang.gmall.promotion.service.rule.profit.impl.GiftStrategyImpl;
import com.ganzalang.gmall.promotion.service.rule.profit.impl.ReducedAmountStrategyImpl;
import com.ganzalang.gmall.promotion.service.rule.profit.impl.ReducedRateStrategyImpl;

/**
 * @description:
 * @author: Ganzalang
 * @Date 2022/4/8 17:21
 */
public class ProfitFactory {

    public static ProfitStrategy getBean(Integer type) {
        ProfitEnum profitEnum = ProfitEnum.valueOf(type);
        switch (profitEnum) {
            case REDUCED_AMOUNT:
                return new ReducedAmountStrategyImpl();
            case REDUCED_RATE:
                return new ReducedRateStrategyImpl();
            case FIX_AMOUNT:
                return new FixAmountStrategyImpl();
            case GIFT:
                return new GiftStrategyImpl();
            default:
                return null;
        }
    }
}
